{subtemplate common/header}
<link rel="stylesheet" type="text/css" href="$_G['siteurl']source/plugin/stu_fitness/css/stu_fitness.css" />
<script  src="$_G['siteurl']source/plugin/stu_fitness/js/jquery.js" ></script>
<!-- 引入全国高校的数据 -->
<script  src="$_G['siteurl']source/plugin/stu_fitness/js/school_data.js" ></script>
<!-- 引入全国省份城市的数据 -->
<script  src="$_G['siteurl']source/plugin/stu_fitness/js/provinces_data.js" ></script>
<script language="javascript" type="text/javascript" src="$_G['siteurl']source/plugin/stu_fitness/js/WdatePicker.js"></script>
<script language="javascript">
	var jq = jQuery.noConflict();
	//把$让给第一个实现它的库，用jq代替,避免和Discuz的冲突
	/*以下是学校选择代码*/
	//弹出窗口
	function pop() {
		//将窗口居中
		makeCenter();

		//初始化省份列表
		initProvince();

		//默认情况下, 给第一个省份添加choosen样式
		jq('[province-id="1"]').addClass('choosen');

		//初始化大学列表
		initSchool(1);
	}

	//隐藏窗口
	function hide() {
		jq('#choose-box-wrapper').css("display", "none");
	}

	function initProvince() {
		//原先的省份列表清空
		jq('#choose-a-province').html('');
		for ( i = 0; i < schoolList.length; i++) {
			jq('#choose-a-province').append('<a class="province-item" province-id="' + schoolList[i].id + '">' + schoolList[i].name + '</a>');
		}
		//添加省份列表项的click事件
		jq('.province-item').bind('click', function() {
			var item = jq(this);
			var province = item.attr('province-id');
			var choosenItem = item.parent().find('.choosen');
			if (choosenItem)
				jq(choosenItem).removeClass('choosen');
			item.addClass('choosen');
			//更新大学列表
			initSchool(province);
		});
	}

	function initSchool(provinceID) {
		//原先的学校列表清空
		jq('#choose-a-school').html('');
		var schools = schoolList[provinceID - 1].school;
		for ( i = 0; i < schools.length; i++) {
			jq('#choose-a-school').append('<a class="school-item" school-id="' + schools[i].id + '">' + schools[i].name + '</a>');
		}
		//添加大学列表项的click事件
		jq('.school-item').bind('click', function() {
			var item = jq(this);
			var school = item.attr('school-id');
			//更新选择大学文本框中的值
			jq('#school-name').val(item.text());
			//关闭弹窗
			hide();
		});
	}
	
	function makeCenter() {
		jq('#choose-box-wrapper').css("display", "block");
		jq('#choose-box-wrapper').css("position", "absolute");
		jq('#choose-box-wrapper').css("top", Math.max(0, ((jq(window).height() - jq('#choose-box-wrapper').outerHeight()) / 2) + jq(window).scrollTop()) + "px");
		jq('#choose-box-wrapper').css("left", Math.max(0, ((jq(window).width() - jq('#choose-box-wrapper').outerWidth()) / 2) + jq(window).scrollLeft()) + "px");
	}

	/*以下是省份和城市的选择代码*/
	jq.each(GP, function(i) {
		jq("#province").append("<option value='" + i + "'>" + GP[i] + "</option>");
	});

	function changeCity(provine) {
		var s = jq(provine).val();
		var city = jq(provine).next("#city");
		city.get(0).selectedIndex = 0;
		if (s != 0) {
			city.empty();
			jq.each(GT[s], function(i) {
				city.append("<option value='" + i + "'>" + GT[s][i] + "</option>");
			});
		}
		/*
		 jq("#city").get(0).selectedIndex = 0;
		 if (s != 0) {
		 jq("#city").empty();
		 jq.each(GT[s], function(i) {
		 jq("#city").append("<option value='" + i + "'>" + GT[s][i] + "</option>");
		 });
		 }*/
	}
	//刷新隐藏的真实值
	function refreshCityValue(selectItem){
		var cityInput 		= jq(selectItem).next('.cityValue');
		var provinceInput 	= jq(selectItem).prev('#province');
		cityInput.val(jq(selectItem).find("option:selected").text()+"-"+provinceInput.find("option:selected").text());
	}
</script>
<!-- 存放选择学校的样式 -->
<link rel="stylesheet" type="text/css" href="$_G['siteurl']source/plugin/stu_fitness/css/School.css" />
<div id="pt" class="wp">
	<div class="z">
		<a href="./" class="nvhm">$_G['setting']['bbname']</a><em>&rsaquo;</em><a href="plugin.php?id=stu_fitness"> <!--{if !empty($ndsquesname)}-->$ndsquesname<!--{else}-->汕大体能插件<!--{/if}--></a>
		<em>&rsaquo;</em>新建问卷
	</div>
</div>
<div id="ct" class="wp cl">
	<div class="mn">
		<div class="bm bml">
			<div class="bm_h cl">
				<h1 class="xs2"> 发布新问卷&nbsp;&nbsp;</h1>
			</div>
		</div>
		<script language="javascript">
			var QNum = 1;
			/*增加问题行*/
			function addRow() {
				var tableObj = document.getElementById("quesbody");
				var newRowObj = tableObj.insertRow(tableObj.rows.length);
				var newColName = newRowObj.insertCell(newRowObj.cells.length);
				newColName.height = "118";
				newColName.colSpan = 2;
				newColName.innerHTML = document.getElementById("QHide_Default").innerHTML;
				QNum++; 
			}
			/*删除问题行*/
			function deleteRow(element)
			{
				if(QNum <= 1){
					alert("删除失败,每份问卷至少有一个问题！");
					return false;
				}
				else{
					var td1=element.parentNode;
				    var tr1=td1.parentNode;
				    var tindex=tr1.rowIndex-1;
				    document.getElementById("quesbody").deleteRow(tindex);
				    QNum--; 
				}
				 
			}
			//增加普通单选
			function addQ_SingleChoose() {
				var HTMLC = document.getElementById("QHide_SignelChoose").innerHTML;
				return HTMLC;
			}

			//增加普通多选
			function addQ_MultiChoose() {
				var HTMLC = document.getElementById("QHide_MultiChoose").innerHTML;
				return HTMLC;
			}

			//增加纯字符填空
			function addQ_ChartInput() {
				var HTMLC = document.getElementById("QHide_ChartInput").innerHTML;
				return HTMLC;
			}

			//增加学校
			function addQ_SchoolChoose() {
				var HTMLC = document.getElementById("QHide_SchoolChoose").innerHTML;
				return HTMLC;
			}

			//增加省份
			function addQ_ProvincesChoose() {
				var HTMLC = document.getElementById("QHide_ProvincesChoose").innerHTML;
				return HTMLC;
			}

			//增加日期
			function addQ_DateChoose() {
				var HTMLC = document.getElementById("QHide_DateChoose").innerHTML;
				return HTMLC;
			}

			//增加数字填空
			function addQ_NumInput() {
				var HTMLC = document.getElementById("QHide_NumInput").innerHTML;
				return HTMLC;
			}

			

			//返回父节点中第一个符合name属性的子节点对象
			function GetChildByName(Parent, Name) {
				var childs = Parent.childNodes;
				var TagChild = null;
				for ( i = 0; i < childs.length; i++) {
					//换行节点的属性attributes是空的
					if ((childs[i].attributes != null) && ( typeof (childs[i].attributes['name']) != "undefined")) {
						if (Name == childs[i].attributes['name'].value) {
							TagChild = childs[i];
							break;
						}
					}
				}
				return TagChild;
			}

			function ShowAnswer(selectedItem) {

				var chooseVal = selectedItem.options[selectedItem.options.selectedIndex].value;
				var AnswerHTML = "";
				var AnswerPlace = GetChildByName(selectedItem.parentNode.parentNode, "AnswerPlace");
				//alert(AnswerPlace);
				//selectedItem.parentNode.parentNode.lastChild;
				switch(chooseVal) {
					//普通单选
					case "1":
						AnswerHTML = addQ_SingleChoose();
						break;
					//普通单选
					case "2":
						AnswerHTML = addQ_MultiChoose();
						break;
					//纯字符填空
					case "3":
						AnswerHTML = addQ_ChartInput();
						break;
					//学校
					case "4":
						AnswerHTML = addQ_SchoolChoose();
						break;
					//省份
					case "5":
						AnswerHTML = addQ_ProvincesChoose();
						break;
					//日期
					case "6":
						AnswerHTML = addQ_DateChoose();
						break;
					//数字填空
					case "7":
						AnswerHTML = addQ_NumInput();
						break;
					default:
						break;

				}
				AnswerPlace.innerHTML = AnswerHTML;
			}

		</script>

		<form  name="newques" method="post" action="plugin.php?id=stu_fitness&action=newques" >
			<input type="hidden" name="formhash" value="{FORMHASH}">
			<input type="hidden" name="newquessubmit" value="true">
			<input type="hidden" name="choiceall" value="">
			<input type="hidden" name="ques_mode" value="$sysmode">
			<div class="main">
				<div class="content">
					<div class="datalist">
						<table  width="100%" cellspacing="0" cellpadding="0" class="datatable">
							<thead class="category">
								<tr>
									<td width="10%"><b>项目</b></td>
									<td width="70%"><b>内容</b></td>
									<td width="20%"><b>帮助</b></td>
								</tr>
							</thead>
							<tr>
								<td>问卷标题</td>
								<td>
								<input type="text" name="subject" size="73">
								</td>
								<td>问卷的标题，必须填写，管理员可使用HTML代码。</td>
							</tr>
							<tr>
								<td>问卷分类</td>
								<td>
								<select name="quesclass">
									<!--{loop $ndsqclass $key $var}-->
									<option value="{$key}">$var</option>
									<!--{/loop}-->
								</select></td>
								<td>问卷分类，请在插件后台设置自己的问卷分类，在此选择。</td>
							</tr>
							<tr>
								<td height="28">有效期(天)</td>
								<td>
								<input type="text" name="exp" size="8" value="100">
								</td>
								<td>问卷有效期，从问卷发布日开始计算起。</td>
							</tr>

							<tr>
								<td>问卷说明</td>
								<td>
								<div class="tedt" style="width: 400px;" >
									<div class="bar">
										{eval $seditor = array('is', array('bold', 'color', 'img', 'link', 'quote', 'code', 'smilies'));}
										{subtemplate common/seditor}
									</div>
									<div class="area">
										<textarea name="message" id="ismessage" rows="5" class="pt" cols="75">$questopic['message']</textarea>
									</div>
								</div></td>
								<td>问卷内容的简要说明，可选择填写，可支持Discuz!代码。</td>
							</tr>
							</table>
							<table>
							<thead class="separation">
								<tr>
									<td width="10%"><a id="addqueslink" href="javascript:void(0)" onclick="addRow('quesbody');">
										<img src="{$imgurl}add.gif" alt="{lang nds_up_ques:addopa}"> 增加</a>
									</td>
									<td width="70%">&nbsp;</td>
									<td width="20%" colspan="2">请在下方增加或编辑问卷题目，一个问卷至少要有一个题目。</td>
								</tr>
							</thead>
							<tbody id="quesbody">
								<tr>
									<td height="118"  colspan="2" class="d2td">
									<a onclick="deleteRow(this);" href="javascript:void(0)"><img alt="删除" src="{$imgurl}del.gif"> 删</a>
									<label><b>顺序</b>&nbsp;&nbsp;</label>
									<input type="text" name="order[]" size="1" value="0">
									&nbsp;&nbsp; <label><b>题目</b>&nbsp;&nbsp;</label>
									<input type="text" name="title[]" size="88">
									<div class="ndsdiv">
										<select name="least[]">
											<option <!--{if $ndsdefleas == 1 }-->selected="selected"<!--{/if}--> value="0">必答题</option>
											<option <!--{if $ndsdefleas == 2 }-->selected="selected"<!--{/if}--> value="1">选答题</option>
										</select>
										&nbsp;&nbsp; <label><b>题型</b>&nbsp;</label>
										<select id= "types" name="types[]" onchange="ShowAnswer(this)">
											<option <!--{if $ndsdeftype == 1 }-->selected="selected"<!--{/if}--> value="1">普通单选</option>
											<option <!--{if $ndsdeftype == 2 }-->selected="selected"<!--{/if}--> value="2">普通多选</option>
											<option <!--{if $ndsdeftype == 3 }-->selected="selected"<!--{/if}--> value="3">纯字符填空</option>
											<option <!--{if $ndsdeftype == 4 }-->selected="selected"<!--{/if}--> value="4">学校</option>
											<option <!--{if $ndsdeftype == 5 }-->selected="selected"<!--{/if}--> value="5">省份</option>
											<option <!--{if $ndsdeftype == 6 }-->selected="selected"<!--{/if}--> value="6">日期</option>
											<option <!--{if $ndsdeftype == 7 }-->selected="selected"<!--{/if}--> value="7">数字填空</option>
										</select>

									</div>
									<div name="AnswerPlace">
										<label><b>选项(每行一项)</b></label>
										<br/>
										<textarea name="options[]" wrap="off" style="width: 250px; height: 90px; font-size: 12px;"></textarea>
									</div>
								</tr>
							</tbody>
						</table>

					</div>
				</div>
			</div>
			
			<a id="addqueslink" href="javascript:void(0)" onclick="addRow();"> <img src="{$imgurl}add.gif" alt="点击增加题目"> 增加 </a>
			<div class="mtm mbm">
				<button type="submit" id="postsubmit" class="pn pnc" value="true" name="newquessubmit_bt" onclick =" return confirm('$mischecktm')">
					<span>提交</span>
				</button>
			</div>
		</form>
	</div>
</div>
<!--
			增加题目的默认模版
			-->
			<div id="QHide_Default" class="hidden">
				<a onclick="deleteRow(this);" href="javascript:void(0)"><img alt="!delopa!" src="$_G['siteurl']source/plugin/stu_fitness/images/del.gif"> 删</a>
				<label><b>顺序</b>&nbsp;&nbsp;</label>
				<input type="text" name="order[]" size="1" value="0">
				&nbsp;&nbsp;
				<label><b>题目</b>&nbsp;&nbsp;</label>
				<input type="text" name="title[]" size="88">
				<div class="ndsdiv">
					<select name="least[]">
						<option value="0">必答题</option>
						<option value="1">选答题</option>
					</select>
					&nbsp;&nbsp;
					<label><b>题型</b>&nbsp;</label>
					<select id="types" name="types[]" onchange="ShowAnswer(this)">
						<option value="1">普通单选</option>
						<option value="2">普通多选</option>
						<option value="3">纯字符填空</option>
						<option value="4">学校</option>
						<option value="5">省份</option>
						<option value="6">日期</option>
						<option value="7">数字填空</option>
					</select>
				</div>
				<label><b>选项</b></label>
				<div name="AnswerPlace">
					<label><b>选项(每行一项)</b></label>
					<br/>
					<textarea name="options[]" style="width: 250px; height: 90px; font-size: 12px;"></textarea>
					<input name="maxNum[]" class="hidden"/>
					<input name="minNum[]" class="hidden"/>
				</div>
			</div>
			<!--
			增加普通单选
			-->
			<div id="QHide_SignelChoose" class="hidden">
				<label><b>选项(每行一项)</b></label><br/>
				<textarea name="options[]" wrap="off" style="width: 250px; height: 90px; font-size: 12px;"></textarea>
				<input name="maxNum[]" type="hidden" />
				<input name="minNum[]" type="hidden"/>
			</div>
			<!--
			增加普通多选
			-->
			<div id="QHide_MultiChoose" class="hidden">
				<label><b>选项(每行一项)</b></label><br/>
				<span id="chmaxsp" name="chmaxsp"> 
					<label class="ndslable"><b>至少选择</b></label>
					<input name="minNum[]" type="text" size="2" maxlength="2">
					<label class="ndslable"><b>最多选择</b></label>
					<input name="maxNum[]" type="text" size="2" maxlength="2">
				</span>
				<br/>
				<textarea name="options[]" wrap="off" style="width: 250px; height: 90px; font-size: 12px;"></textarea>
			</div>
			<!--
			增加纯字符填空
			-->
			<div id="QHide_ChartInput" class="hidden">
				<label><b>可以输入默认文字</b></label><br/>
				<input type="text" name="options[]" placeholder="请输入提示文字" />
				<input name="maxNum[]" type="hidden" />
				<input name="minNum[]" type="hidden"/>
			</div>
			<!--
			增加学校
			-->
			<div id="QHide_SchoolChoose" class="hidden">
				<label><b>选择大学</b></label><br/>
				<input type="text" name="options[]" id="school-name" value="请选择大学" onclick="pop()">
				<input name="maxNum[]" type="hidden" />
				<input name="minNum[]" type="hidden"/>
				<div id="choose-box-wrapper">
					<div id="choose-box">
						<div id="choose-box-title">
							<span>选择学校</span>
						</div>
						<div id="choose-a-province"></div>
						<div id="choose-a-school"></div>
						<div id="choose-box-bottom">
							<input type="botton" onclick="hide()" value="关闭" />
						</div>
					</div>
				</div>
			</div>
			<!--
			增加省份
			-->
			<div id="QHide_ProvincesChoose" class="hidden">
				<label><b>可以选择默认城市</b></label><br/>
				<select  id="province" name="" size="" onclick="changeCity(this)" ></select>
				<select  id="city" onchange="refreshCityValue(this)" name="" size="">
					<option value="0">请选择城市</option>
				</select>
				<input  type="hidden" class="cityValue" name="options[]"/>
			</div>
				<input name="maxNum[]" type="hidden" />
				<input name="minNum[]" type="hidden"/>
			<script>
				jq.each(GP, function(i) {
					jq("#province").append("<option value='" + i + "'>" + GP[i] + "</option>");
				});
			</script>
			<!--
			增加日期
			-->
			<div id="QHide_DateChoose" class="hidden">
				<label><b>可以选择默认日期</b></label><br/>
				<input class="Wdate" type="date" name="options[]"  onClick="WdatePicker()">
				<input name="maxNum[]" type="hidden" />
				<input name="minNum[]" type="hidden"/>
			</div>
			<!--
			增加数字填空
			-->
			<div id="QHide_NumInput" class="hidden">
				<label><b>可以输入默认数字</b></label><br/>
				<span id="chmaxsp" name="chmaxsp"> 
					<label class="ndslable"><b>小于</b></label>
					<input name="minNum[]" type="number" size="2" maxlength="2">
					<label class="ndslable"><b>大于</b></label>
					<input name="maxNum[]" type="number" size="2" maxlength="2">
				</span>
				<br />
				<input type="number" name="options[]"  placeholder="请输入默认的数字(可以为空)" />
			</div>
			
			
{subtemplate common/footer}
